#pragma once
class HighScoreEntry
{
public:
	//=== vars ===//
	int					m_iScore;			// score of level
	int					m_iPlayTime;		// amount of time in seconds to complete level
	irr::core::stringc	m_strUserName;		// name of player with high score

	//=== constructor ===//
	HighScoreEntry()
		: m_iScore(0)
		, m_iPlayTime(0)
	{
		// empty
	}
	//=== methods ===//
	//! format entry for display
	void			GetFormatedHighScore( irr::core::stringw& strRetFormatedEntry );
};
class HighScores 
{
public:
	// storage
	irr::core::stringc					m_strConfigFile;
	// scores
	irr::core::array<HighScoreEntry>	m_aoEasyHighScores;			// array of high scores for easy level
	irr::core::array<HighScoreEntry>	m_aoMediumHighScores;		// array of high scores for medium level
	irr::core::array<HighScoreEntry>	m_aoHardHighScores;			// array of high scores for medium level
	// 

	//! initialize and load from xml file
	RCODE			Startup( const char * pConfigXmlFileName );
	//! shutdown
	RCODE			Shutdown( void );

	//! read settings from file
	RCODE			ReadConfig( void );
	//! write settings from file
	RCODE			WriteConfig( void );

	//! return true if is better score than existing score and belongs in top ten scores
	BOOL			IsHighScore( int iLevel, int iScore, int iTime );

	//! add new high score
	RCODE			AddHighScore( int iLevel, const char * pName, int iScore, int iTime );


private:
	//helpers
	//! reset settings to default
	void			Reset( void );
	//! read level scores from file
	RCODE	ReadLevelScores( TiXmlElement * poScoresElement, const char * pLevelName, irr::core::array<HighScoreEntry>& aoScores );
	//! write level scores to file
	RCODE	WriteLevelScores( TiXmlElement * poScoresElement, const char * pLevelName, irr::core::array<HighScoreEntry>& aoScores );
	//! check if score is higher than any existing score
	BOOL	CheckIsHighScore( irr::core::array<HighScoreEntry>& aoScores, int iLevel, int iScore, int iTime );
	//! add new high score
	RCODE	DoAddHighScore( irr::core::array<HighScoreEntry>& aoScores, int iLevel, const char * pName, int iScore, int iTime );



};

typedef VxSingleton<HighScores> HighScoresImp;
